﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace Erebos.GameScreenFiles.WorldObjects
{
    class SmokePlumeObject : Object
    {
        private ParticleSystem _smokePlumeParticles;

        private Vector3 _position;

        public SmokePlumeObject(Vector3 position, Vector3 gravity)
        {
            _position = position;

            _smokePlumeParticles = new SmokePlumeParticleSystem(MainGame.Game, MainGame.GetContentManager(), gravity);

            MainGame.Game.Components.Add(_smokePlumeParticles);
        }

        public override void Draw(GameTime gameTime)
        {
            _smokePlumeParticles.SetCamera(Camera.ViewMatrix, Camera.ProjectionMatrix);

            base.Draw(gameTime);
        }

        public override void Update(GameTime gameTime)
        {
            _smokePlumeParticles.DrawOrder = 2024 * 2024 - (int)Vector2.Distance(new Vector2(Camera.CameraPosition.X, -Camera.CameraPosition.Z), new Vector2(_position.X, _position.Z));

            _smokePlumeParticles.AddParticle(new Vector3(_position.X, _position.Y, -_position.Z), Vector3.Zero);

            base.Update(gameTime);
        }
    }
}
